package com.kust.smarthome.web.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kust.smarthome.web.dto.ShopDto;
import com.kust.smarthome.web.model.Shop;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author iAuzre
 * @since 2021-07-09
 */
@Repository
public interface ShopMapper extends BaseMapper<Shop> {

    /*id name intro money imgurl1*/
    @Select("select s.id as id," +
            "c.id as commodityId," +
            "c.name as name," +
            "c.intro as intro," +
            "c.money as money," +
            "s.commodity_number as commodityNumber," +
            "c.imgurl1 as imgurl1 " +
            "from shop s " +
            "left join commodity c on s.commodity_id=c.id " +
            "where s.user_id=#{userId}")
    List<ShopDto> getShopList(Integer userId);

}
